﻿@model IEnumerable<Property4U.Models.Ad>

@{
    ViewBag.Title = "Ads";
}

@helper  ConvertBytes(string IBytes)
{

    double IBytesI = Convert.ToDouble(IBytes);
    string sSize = string.Empty;

    if (IBytesI >= 1073741824)
    {
        @(String.Format("{0:##.##}", IBytesI / 1073741824) + " GB");
    }
    else if (IBytesI >= 1048576)
    {
        @(String.Format("{0:##.##}", IBytesI / 1048576) + " MB");
    }
    else if (IBytesI >= 1024)
    {
        @(String.Format("{0:##.##}", IBytesI / 1024) + " KB");
    }
    else if (IBytesI > 0 && IBytesI < 1024)
    {
        @(IBytes.ToString() + " bytes");
    }
}

<div class="row">
    <!-- Page Header -->
    <div class="col-lg-12">
        <h1 class="page-header">@ViewBag.Title</h1>
    </div>
    <!--End Page Header -->
</div>

<p>
    @Html.ActionLink("Create New", "Create")
</p>
<table class="table">
    <tr>
        <th>
            <label>AdminID</label>
        </th>
        <th>
            <label>OrderID</label>
        </th>
        <th>
            @Html.DisplayNameFor(model => model.Title)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.Path)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.ImageSize)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.AdDuration)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.AdStatus)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.Remedies)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.PostedOn)
        </th>
        <th></th>
    </tr>

@foreach (var item in Model) {
    <tr>
        <td>
            @Html.DisplayFor(modelItem => item.Admin.Id)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.Order.ID)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.Title)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.Path)
        </td>
        <td>
            @ConvertBytes(item.ImageSize.ToString())
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.AdDuration)
        </td>
        <td>
            <span class="progress status-@item.AdStatus">
                @Html.DisplayFor(modelItem => item.AdStatus)
            </span>
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.Remedies)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.PostedOn)
        </td>
        <td>
            @Html.ActionLink("Edit", "Edit", new { id=item.ID }) |
            @Html.ActionLink("Details", "Details", new { id=item.ID }) |
            @Html.ActionLink("Delete", "Delete", new { id=item.ID })
        </td>
    </tr>
}

</table>
